/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package researchgrants.parts.LoggedData.panels;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.event.ChangeEvent;

/**
 *
 * @author DOStudent1
 */
public class LoggedDataPanelsTextArea extends LoggedDataPanels implements ActionListener {
    private static final int MIN_SIZE_X=30;
    private static final int MIN_SIZE_Y=4;

    @Override
    public Component getViewComponent() {
        validateDataToDisplay();
        JTextArea textarea=new JTextArea(MIN_SIZE_Y, MIN_SIZE_X);
        textarea.setText(getData().value());
        textarea.setEditable(false);
        JScrollPane pane=new JScrollPane(textarea);
        return(pane);
    }

    JTextArea fldEditText;

    @Override
    public Component getEditComponent() {
        fldEditText=new JTextArea(MIN_SIZE_Y, MIN_SIZE_X);
        if (hasDataInitialized()) {
            fldEditText.setText(getData().value());
        } else {
            fldEditText.setText(getDefaultValue());
        }
        JScrollPane pane=new JScrollPane(fldEditText);
        return(pane);
    }

    @Override
    public String getEdittedValue() {
        return(fldEditText.getText());
    }
    
    
    @Override
    public void actionPerformed(ActionEvent e) {
        ChangeEvent eNew=new ChangeEvent(e.getSource());
        notifyAllChangeListeners(eNew);
    }
    
    @Override
    public boolean isEmpty() {
        return(fldEditText.getText().equals(""));
    }

    @Override
    public boolean isValid() {
        return(true);
    }

    
}
